home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / egxshow.arc / EGAWORLD.C < prev    next >
Text File  |  1991-09-17  |  20KB  |  693 lines

  1. /* egaworld by bill buckels 1991 */
  2. /* use bresenham's algorithm to draw lines */
  3. /* using the writepixel subroutine         */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <fcntl.h>
  8. #include <string.h>
  9. #include <dos.h>
  10. #include <bios.h>
  11. #include <io.h>
  12. #include <malloc.h>
  13. #include <conio.h>
  14.  
  15. #define BLACK     0
  16. #define BLUE      1
  17. #define GREEN     2
  18. #define CYAN      3
  19. #define RED       4
  20. #define MAGENTA   5
  21. #define BROWN     6
  22. #define WHITE     7
  23. #define GRAY      8
  24. #define LBLUE     9
  25. #define LGREEN    10
  26. #define LCYAN     11
  27. #define LRED      12
  28. #define LMAGENTA  13
  29. #define YELLOW    14
  30. #define BWHITE    15
  31.  
  32.  
  33.  
  34. #define EGA  '\x10'
  35. #define TEXT '\x03'
  36.  
  37. unsigned char setcrtmode(unsigned char vidmode)
  38. {
  39.     union REGS inregs, outregs;
  40.  
  41.     /* set mode */
  42.     inregs.h.ah = 0;
  43.     inregs.h.al = vidmode;
  44.     int86( 0x10, &inregs, &outregs );
  45.  
  46.     /* get mode */
  47.     inregs.h.ah = 0xf;
  48.     int86( 0x10, &inregs, &outregs );
  49.  
  50.     /* return mode */
  51.     return outregs.h.al;
  52.  
  53. }
  54.  
  55. void flood(unsigned char floodcolor)
  56. {
  57.     union REGS rin,rout;
  58.  
  59.     rin.h.dh =43;
  60.     rin.h.dl =79;
  61.     rin.x.cx = 0;
  62.     rin.h.bh= floodcolor;
  63.     rin.x.ax= 0x0600;
  64.     int86(0x10,&rin,&rout);
  65. }
  66.  
  67.  
  68. void writepixel(unsigned x, unsigned y, unsigned color)
  69. {
  70.    union REGS reg;
  71.  
  72.    reg.h.ah = 0x0c;
  73.    reg.h.al = (char )color;
  74.    reg.h.bh = 0;
  75.    reg.x.cx = x;
  76.    reg.x.dx = y;
  77.  
  78.    int86(0x10,®,®);
  79.  
  80. }
  81.  
  82.  
  83. void linebox(int x1, int y1, int x2, int y2,unsigned tempcolor)
  84. {
  85.     register x,y;
  86.  
  87.     x2++;
  88.     x=x1;
  89.     y=y1;
  90.     while(x<x2)
  91.     {
  92.       writepixel(x,y,tempcolor);
  93.       x++;
  94.     }
  95.     y++;
  96.     x2--;
  97.     while(y<y2)
  98.     {
  99.         writepixel(x1,y,tempcolor);
  100.         writepixel(x2,y,tempcolor);
  101.         y++;
  102.         }
  103.  
  104.      x2++;
  105.      x=x1;
  106.      while(x<x2)
  107.     {
  108.       writepixel(x,y,tempcolor);
  109.       x++;
  110.     }
  111.  
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. void writeline(int x1,int y1,int x2,int y2,unsigned color)
  120. {
  121.     union REGS inregs, outregs;
  122.     #define sign(x) ((x)>0?1:((x)==0?0:(-1)))
  123.     int dx,dy,dxabs,dyabs,i,px,py,sdx,sdy,x,y;
  124.  
  125.      inregs.h.ah = 0x0c;
  126.      inregs.h.al = (char )color;
  127.      inregs.h.bh = 0;
  128.  
  129.  
  130.     dx=x2-x1;
  131.     dy=y2-y1;
  132.     sdx=sign(dx);
  133.     sdy=sign(dy);
  134.     dxabs=abs(dx);
  135.     dyabs=abs(dy);
  136.     x=0;
  137.     y=0;
  138.     px=x1;
  139.     py=y1;
  140.  
  141.     if(dxabs >= dyabs)
  142.     {
  143.         for(i=0;i<=dxabs;i++)
  144.         {
  145.             y+=dyabs;
  146.             if(y>=dxabs)
  147.             {y-=dxabs;
  148.              py+=sdy;
  149.             }
  150.             inregs.x.cx = px;
  151.             inregs.x.dx = py;
  152.             int86(0x10,&inregs,&outregs);
  153.             px+=sdx;
  154.         }
  155.     }
  156.     else{
  157.         for(i=0;i<=dyabs;i++)
  158.         {
  159.             x+=dxabs;
  160.             if(x>=dyabs)
  161.             {
  162.                 x-=dyabs;
  163.                 px+=sdx;
  164.             }
  165.             inregs.x.cx = px;
  166.             inregs.x.dx = py;
  167.             int86(0x10,&inregs,&outregs);
  168.             py+=sdy;
  169.         }
  170.     }
  171. }
  172.  
  173.  
  174. #define CRETURN '\x0d'
  175.  
  176. int egatext(char *str, unsigned x, unsigned y, unsigned colorvalue)
  177. {
  178.  
  179.     union REGS inregs, outregs;
  180.  
  181.     int scanline,byte,character,nibble;   /* flags etcetera */
  182.     int counter;
  183.     unsigned char *romfont=(unsigned char *) 0xffa6000el;
  184.     /* a pointer to the 8 x 8 BITMAPPED font in the PC ROM    */
  185.  
  186.     int target = strlen(str);  /* string length               */
  187.  
  188.     if(!target)return 0;
  189.     for(counter=0;counter<target;counter++){
  190.         if(str[counter]<' '||str[counter]>'z')str[counter]=0;
  191.         if(str[counter]==CRETURN)target=counter;
  192.         }
  193.  
  194.      inregs.h.ah = 0x0c;
  195.      inregs.h.al = (char )colorvalue;
  196.      inregs.h.bh = 0;
  197.  
  198.  
  199.  
  200.     for (scanline=0;scanline<8;scanline++) /* finish the current scanline
  201.                                               before advancing to the next */
  202.     {
  203.      for (byte=0;byte<target;byte++)         /* run the scanline           */
  204.      {                                       /* use the current character
  205.                                                 as an indices for the font */
  206.       character = romfont[(str[byte]&0x7f)*8+scanline];
  207.       if (character != 0)
  208.           for (nibble=0;nibble<8;nibble++)
  209.               if (character & 0x80>>nibble)
  210.                        {
  211.                          inregs.x.cx = x+byte*8+nibble;
  212.                          inregs.x.dx = y;
  213.                          int86(0x10,&inregs,&outregs);
  214.                         }
  215.         }
  216.  
  217.      y++;
  218.     }
  219.     return target;
  220.  
  221. }
  222.  
  223. /* center justified x-dimension only */
  224. int egatextM(unsigned char *str,unsigned xorigin,unsigned yorigin,
  225.               unsigned tempcolor)
  226. {
  227.     int target = strlen(str);    /* string length               */
  228.     int counter;
  229.  
  230.     if(!target)return 0;
  231.  
  232.     for(counter=0;counter<target;counter++){
  233.         if(str[counter]<' '||str[counter]>'z')str[counter]=0;
  234.         if(str[counter]==CRETURN)target=counter;
  235.         }
  236.     xorigin=(xorigin-(target*4));/* extrapolate the left edge   */
  237.     egatext(str,xorigin,yorigin,tempcolor); /* pass to the usual function  */
  238.     return target;
  239.  
  240. }
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247. int USA[]=
  248. {
  249. /* data statements */
  250.  
  251. 26,12,32,13,33,14,35,15,34,17,32,18,31,19,31,22,34,22,35,20,36,20,37,
  252. 18,37,10,36,8,40,8,42,9,44,10,48,12,54,14,62,16,70,18,78,19,86,20,102,
  253. 21,134,21,150,20,165,20,165,18,168,18,168,20,172,22,176,22,182,24,186,
  254. 25,192,24,193,24,193,25,192,26,190,28,186,30,184,32,182,34,181,36,184,
  255. 35,186,34,189,34,188,36,190,36,192,35,194,34,196,32,198,32,201,28,203,
  256. 28,200,32,199,33,200,33,202,32,206,36,209,36,210,33,214,33,217,31,218,
  257. 31,218,32,216,34,222,33,223,36,221,36,220,38,218,37,217,36,214,37,211,
  258. 39,208,39,206,42,203,48,202,50,208,44,208,46,206,50,205,51,204,59,205,
  259. 64,207,68,208,70,210,70,212,68,214,64,214,62,213,60,212,56,213,54,212,
  260. 53,212,48,214,46,215,48,216,44,218,42,217,40,220,39,224,40,226,42,226,
  261. 44,228,46,227,48,225,52,226,54,227,52,228,52,229,51,231,51,232,54,232,
  262. 56,233,58,234,59,232,61,229,67,234,69,238,68,241,67,243,64,245,64,247,
  263. 62,251,60,251,53,258,52,262,50,264,50,264,45,262,44,262,43,264,43,266,
  264. 40,268,36,273,35,280,32,284,31,286,28,289,28,289,24,290,22,289,21,291,
  265. 15,290,12,290,9,291,9,294,11,296,9,298,10,301,16,303,22,306,24,310,24,
  266. 310,28,307,29,304,31,304,33,302,31,299,32,299,36,294,39,296,40,294,42,
  267. 294,48,297,53,297,54,296,55,296,56,292,58,290,58,289,59,286,59,282,64,
  268. 280,68,282,68,282,74,281,76,280,77,277,77,274,76,279,81,277,83,278,86,
  269. 277,90,278,93,277,95,276,92,276,88,274,86,273,84,272,77,270,80,270,86,
  270. 272,89,274,92,274,94,275,96,278,100,280,102,280,105,276,110,278,110,277,
  271. 112,274,112,270,115,269,119,266,120,264,122,262,126,258,132,256,132,252,
  272. 140,252,142,254,152,258,160,262,164,266,172,266,182,265,184,262,186,260,
  273. 184,258,180,256,180,255,179,252,174,252,173,250,173,248,169,248,166,247,
  274. 167,246,166,246,160,238,152,236,152,236,155,234,156,228,156,226,152,214,
  275. 152,212,153,207,153,206,152,200,154,194,153,194,155,199,159,203,157,202,
  276. 160,202,161,203,162,200,162,199,163,198,163,197,164,194,164,192,162,191,
  277. 159,191,157,189,156,189,157,187,157,186,156,185,160,172,160,162,167,162,
  278. 168,160,168,159,167,158,168,157,171,153,176,152,178,152,180,154,188,152,
  279. 188,150,187,146,186,142,184,140,182,138,180,136,172,133,168,131,166,130,
  280. 162,130,160,126,158,119,158,118,160,115,164,110,160,106,158,106,153,104,
  281. 150,102,148,100,144,97,140,86,140,86,142,83,142,70,140,48,128,48,126,34,
  282. 124,34,120,30,113,26,110,25,108,18,106,18,104,16,100,13,98,13,95,14,94,
  283. 12,90,13,88,13,85,12,84,12,82,10,80,10,68,9,66,9,63,12,56,13,54,13,51,14,
  284. 49,14,46,15,44,16,45,18,40,22,32,22,30,24,24,24,21,26,20,25,18,25,16,24,
  285. 14,26,12,-1,-1,
  286. /*       End of Outline. Draw the States       */
  287.  
  288. 286,28,286,29,288,32,290,36,292,40,294,44,-1,-1,285,30,285,32,
  289. 285,33,285,40,284,43,284,50,281,51,280,48,278,43,277,40,275,34,-1,-1,
  290. 294,46,290,48,284,50,281,51,282,56,286,55,290,54,294,54,296,55,-1,-1,
  291. 290,54,291,58,-1,-1,282,56,283,62,-1,-1,282,64,280,62,276,62,274,61,
  292. 273,56,270,56,249,64,248,62,-1,-1,276,62,274,64,274,68,277,71,277,73,
  293. 276,74,274,76,278,78,278,79,-1,-1,245,64,249,80,273,75,273,77,274,77,
  294. 274,76,-1,-1,254,79,255,82,260,80,264,80,267,81,269,81,269,86,270,86,
  295. -1,-1,273,76,275,85,278,84,-1,-1,259,81,259,83,256,86,256,88,254,88,
  296. 251,96,248,98,245,99,243,98,241,100,238,101,238,102,234,104,248,104,
  297. 278,99,-1,-1,244,104,238,110,234,112,231,115,250,113,253,115,260,114,
  298. 265,115,269,118,-1,-1,238,114,238,120,240,120,241,124,242,124,253,136,
  299. -1,-1,231,116,222,118,226,128,228,136,230,144,231,148,247,148,248,150,
  300. 250,146,253,146,-1,-1,231,148,214,148,214,152,-1,-1,210,153,208,119,
  301. 222,118,-1,-1,208,119,197,120,192,128,190,132,192,132,192,136,193,140,
  302. 192,144,190,148,190,152,194,158,198,158,-1,-1,197,120,198,117,198,110,
  303. 230,107,234,104,-1,-1,199,110,200,108,202,107,201,105,202,104,204,104,
  304. 206,102,208,98,210,97,221,97,221,96,220,95,220,93,222,92,222,90,224,
  305. 90,224,86,226,86,230,89,233,89,235,88,238,90,238,94,242,96,243,98,-1,-1,
  306. 238,90,240,86,241,86,245,82,246,80,246,79,248,76,-1,-1,224,86,222,68,
  307. -1,-1,229,67,212,68,-1,-1,209,70,209,88,207,94,207,100,-1,-1,201,105,
  308. 200,104,199,103,199,102,194,96,194,92,192,92,189,88,187,86,187,84,188,
  309. 80,190,77,189,74,193,72,193,70,192,68,188,64,-1,-1,205,64,188,64,186,
  310. 60,186,54,180,52,179,50,178,50,178,43,181,40,181,36,183,35,-1,-1,192,
  311. 35,193,38,198,40,201,40,203,41,204,45,-1,-1,158,20,158,30,159,31,159,
  312. 39,160,40,160,43,158,44,158,46,160,47,160,60,186,60,-1,-1,160,60,159,
  313. 60,159,62,158,63,158,66,160,68,162,72,162,80,189,80,-1,-1,162,80,164,
  314. 82,164,83,166,84,168,85,167,88,168,90,169,91,169,92,170,92,170,110,
  315. 196,110,198,112,-1,-1,170,110,170,132,173,132,174,133,174,136,192,136,
  316. -1,-1,174,136,172,140,172,142,176,146,178,150,178,154,176,160,-1,-1,
  317. 123,21,122,40,159,42,-1,-1,122,40,120,62,156,64,158,65,-1,-1,120,62,
  318. 118,75,128,76,128,84,166,84,-1,-1,128,84,128,106,170,106,-1,-1,128,
  319. 106,122,106,121,110,138,110,138,124,142,125,143,127,150,128,158,130,
  320. 161,130,165,129,170,132,-1,-1,121,110,118,140,97,140,-1,-1,80,141,88,
  321. 102,122,106,-1,-1,88,102,91,72,118,75,-1,-1,91,72,80,70,86,42,122,46,
  322. -1,-1,86,44,78,43,74,43,72,34,71,33,69,34,68,34,71,27,67,22,68,18,
  323. -1,-1,63,17,57,32,59,33,56,36,56,40,55,42,55,44,54,46,52,53,52,55,51,
  324. 56,82,64,-1,-1,66,60,58,96,88,102,-1,-1,58,96,58,102,57,102,54,100,52,
  325. 108,54,112,54,116,52,116,48,123,49,124,49,126,48,126,-1,-1,56,37,54,36,
  326. 53,37,46,35,42,34,38,32,36,32,34,31,33,31,34,30,29,27,26,26,24,26,-1,-1,
  327. 14,46,51,56,-1,-1,36,52,28,73,52,108,-1,-2
  328. };
  329.  
  330.  
  331. /* we could use the following coordinates to set up a grid or
  332.    a fill mask for each state. not used at this time.
  333.    fields of the array have the following format:
  334.    STATE   CAPITAL   HOT POINT  X,Y
  335.  
  336. */
  337.  
  338. char *STATES[]=
  339. {
  340.  
  341. "ALABAMA","MONTGOMERY","220","130",
  342. "ARIZONA","PHOENIX","70","120",
  343. "NEW MEXICO","SANTA FE","90","120",
  344. "ARKANSAS","LITTLE ROCK","180","120",
  345. "CALIFORNIA","SACRAMENTO","40","120",
  346. "COLORADO","DENVER","110","90",
  347. "CONNECTICUT","HARTFORD","288","57",
  348. "RHODE ISLAND","PROVIDENCE","294","56",
  349. "DELAWARE","DOVER","276","81",
  350. "MARYLAND","ANNAPOLIS","268","78",
  351. "FLORIDA","TALLAHASSEE","260","176",
  352. "GEORGIA","ATLANTA","250","142",
  353. "IDAHO","BOISE","70","50",
  354. "ILLINOIS","SPRINGFIELD","200","80",
  355. "INDIANA","INDIANAPOLIS","214","80",
  356. "IOWA","DES MOINES","170","70",
  357. "KANSAS","TOPEKA","150","90",
  358. "KENTUCKY","FRANKFORT","214","100",
  359. "LOUISIANA","BATON ROUGE","180","140",
  360. "MAINE","AUGUSTA","294","20",
  361. "MASSACHUSETTS","BOSTON","290","52",
  362. "MICHIGAN","LANSING","220","50",
  363. "MICHIGAN","LANSING","206","38",     /* paint twice */
  364. "MINNESOTA","ST PAUL","180","28",
  365. "MISSISSIPPI","JACKSON","200","140",
  366. "MISSOURI","JEFFERSON CITY","180","90",
  367. "MONTANA","HELENA","100","30",
  368. "NEBRASKA","LINCOLN","140","70",
  369. "NEVADA","CARSON CITY","40","70",
  370. "UTAH","SALT LAKE CITY","70","70",
  371. "NEW HAMPSHIRE","CONCORD","290","40",
  372. "VERMONT","MONTPELIER","282","40",
  373. "NEW JERSEY","TRENTON","280","70",
  374. "NEW YORK","ALBANY","280","56",
  375. "N. CAROLINA","RALEIGH","270","110",
  376. "N. DAKOTA","BISMARCK","140","30",
  377. "S. DAKOTA","PIERRE","140","50",
  378. "OHIO","COLUMBUS","240","70",
  379. "OKLAHOMA","OKLAHOMA CITY","150","120",
  380. "OREGON","SALEM","50","40",
  381. "PENNSYLVANIA","HARRISBURG","260","70",
  382. "S. CAROLINA","COLUMBIA","254","120",
  383. "TENNESSEE","NASHVILLE","210","116",
  384. "TEXAS","AUSTIN","140","150",
  385. "VIRGINA","RICHMOND","260","90",
  386. "WASHINGTON","OLYMPIA","40","24",
  387. "W. VIRGINIA","CHARLESTON","246","88",
  388. "WISCONSIN","MADISON","200","50",
  389. "WYOMING","CHEYENNE","100","60",
  390. "-1","-1","-1","-1"
  391. };
  392.  
  393. /* the coordinates to draw the whole world */
  394.  
  395. int WORLD[]=
  396. {
  397.  
  398.    4,32,
  399.    6,32,  6,30,  8,28, 12,28,
  400.    12,24, 16,24, 18,20, 20,20,
  401.    24,18, 30,18, 34,20, 38,22,
  402.    50,22, 54,24, 54,26, 60,26,
  403.    60,24, 56,24, 56,20, 52,20,
  404.    52,18, 56,16, 60,16, 60,18,
  405.    64,20, 64,18, 66,18, 66,24,
  406.    62,24, 64,26, 70,26, 70,22,
  407.    74,18, 78,18, 72,24, 78,24,
  408.    78,20, 80,18, 86,18, 92,24,
  409.    92,28, 86,34, 80,30, 80,28,
  410.    84,28, 86,26, 84,24, 80,24,
  411.    80,26, 76,28, 76,32, 68,32,
  412.    60,38, 60,40, 66,44, 68,44,
  413.    68,50, 74,42, 72,38, 78,34,
  414.    80,34, 82,36, 82,38, 86,36,
  415.    88,44, 92,46, 92,48, 90,48,
  416.    90,50, 90,52, 92,52, 92,56,
  417.    86,54, 86,52, 90,50, 84,50,
  418.    78,50, 80,54, 80,60, 74,60,
  419.    64,70, 64,74, 56,78, 58,86,
  420.    56,88, 54,86, 52,80, 48,80,
  421.    48,82, 42,82, 36,88, 36,92,
  422.    34,94, 38,98, 42,96, 42,92,
  423.    48,92, 44,102, 50,102, 50,110,
  424.    56,110, 56,112, 58,112, 64,106,
  425.    70,110, 72,108, 84,116, 88,116,
  426.    90,120, 90,124, 94,124, 96,128,
  427.    102,128, 108,132, 108,136, 104,142,
  428.    104,152, 96,160, 96,166, 90,174,
  429.    90,176, 84,182, 84,188, 86,190,
  430.    86,198, 90,200, 84,200, 86,198,
  431.    82,200, 76,192, 70,176, 70,166,
  432.    68,152, 60,148, 60,146, 52,132,
  433.    52,124, 56,114, 54,112, 48,112,
  434.    44,106, 42,106, 42,104, 38,104,
  435.    38,102, 32,102, 24,98, 26,94,
  436.    20,80, 22,92, 20,92, 16,84,
  437.    16,76, 14,74, 14,64, 22,54,
  438.    24,54, 24,52, 22,48, 24,38,
  439.    18,34, 14,36, 12,36, 12,38,
  440.    8,38, 4,40, 4,32,
  441.  
  442.   -1,-1,62,16,
  443.    68,14, 70,16, 64,18, 62,16,
  444.  
  445.   -1,-1,68,18,
  446.    72,18, 68,22, 68,18,
  447.  
  448.   -1,-1,72,14,
  449.    76,14, 76,16, 72,16, 72,14,
  450.  
  451.   -1,-1,84,14,
  452.    92,8, 88,8, 86,12, 82,12,
  453.    82,10, 88,8, 96,4, 100,4,
  454.    102,6, 100,8, 108,6, 116,6,
  455.    122,2, 128,2, 130,6, 134,6,
  456.    134,8, 130,16, 128,16, 124,20,
  457.    126,20, 126,22, 118,24, 116,28,
  458.    114,28, 106,38, 102,36, 98,28,
  459.    102,24, 102,22, 104,22, 104,16,
  460.    96,16, 94,14, 100,8, 96,8,
  461.    90,16, 88,14, 84,14,
  462.  
  463.   -1,-1,124,26,
  464.    132,26, 134,28, 128,32, 124,28,
  465.    124,26,
  466.  
  467.   -1,-1,50,92,
  468.    52,90, 56,90, 62,94, 58,96,
  469.    58,94, 50,92,
  470.  
  471.   -1,-1,64,94,
  472.    68,96, 64,98, 62,96, 64,94,
  473.  
  474.   -1,-1,156,10,
  475.    160,10, 162,12, 158,14, 156,10,
  476.  
  477.   -1,-1,162,8,
  478.    164,8, 164,10, 162,8,
  479.  
  480.   -1,-1,162,12,
  481.    164,12, 164,14, 162,12,
  482.  
  483.   -1,-1,188,20,
  484.    188,16, 194,12, 196,12, 196,14,
  485.    190,18, 190,20, 188,20,
  486.  
  487.   -1,-1,192,140,
  488.    196,138, 196,136, 198,134, 200,140,
  489.    196,152, 192,154, 190,150, 192,140,
  490.  
  491.   -1,-1,280,40,
  492.    286,46, 286,50, 284,50, 280,40,
  493.  
  494.   -1,-1,286,52,
  495.    290,52, 292,54, 288,58, 286,52,
  496.  
  497.   -1,-1,290,58,
  498.    294,60, 294,66, 286,72, 284,70,
  499.    288,68, 284,68, 290,64, 290,58,
  500.  
  501.   -1,-1,278,80,
  502.    280,80, 280,86, 278,84, 278,80,
  503.  
  504.   -1,-1,280,92,
  505.    282,90, 284,96, 286,100, 284,100,
  506.    278,96, 280,92,
  507.  
  508.   -1,-1,280,102,
  509.    280,104, 278,106, 280,102,
  510.  
  511.   -1,-1,284,100,
  512.    286,104, 284,104, 284,100,
  513.  
  514.   -1,-1,288,104,
  515.    290,106, 288,112, 286,110, 286,108,
  516.    284,108, 284,106, 284,104, 286,104,
  517.    288,104,
  518.  
  519.   -1,-1,276,108,
  520.    280,108, 280,120, 276,124, 270,124,
  521.    268,120, 268,114, 272,114, 276,108,
  522.  
  523.   -1,-1,282,116,
  524.    288,116, 288,118, 284,118, 286,128,
  525.    282,128, 280,124, 282,116,
  526.  
  527.   -1,-1,290,116,
  528.    292,116, 292,118, 290,118, 290,116,
  529.  
  530.   -1,-1,294,118,
  531.    298,118, 300,120, 304,120, 312,124,
  532.    316,128, 320,128, 316,132, 320,136,
  533.    314,136, 310,132, 304,134, 302,128,
  534.    296,124, 294,118,
  535.  
  536.   -1,-1,286,132,
  537.    280,132, 280,134, 282,134,
  538.  
  539.   -1,-1,286,134,
  540.    288,132,
  541.  
  542.   -1,-1,320,172,
  543.    324,172, 326,180, 320,186, 318,184,
  544.    308,192, 304,192, 304,190, 316,182,
  545.    318,184, 318,180, 322,178, 320,172,
  546.  
  547.   -1,-1,266,170,
  548.    268,166, 268,152, 272,148, 276,148,
  549.    286,140, 290,140, 296,136, 300,136,
  550.    300,140, 304,144, 306,136, 308,136,
  551.    312,152, 316,156, 304,176, 292,178,
  552.    296,180, 296,182, 292,184, 292,178,
  553.    288,168, 278,168, 278,170, 268,170,
  554.    266,168,
  555.  
  556.   -1,-1,252,110,
  557.    254,110, 266,122, 264,130, 272,132,
  558.    274,130, 272,128, 262,128, 252,114,
  559.    252,110,
  560.  
  561.   -1,-1,136,40,
  562.    140,38, 142,40, 142,44, 144,46,
  563.    144,48, 136,50, 138,44, 136,40,
  564.  
  565.   -1,-1,136,44,
  566.    136,48, 132,48, 134,44, 136,44,
  567.  
  568.   -1,-1,130,72,
  569.    120,88, 120,104, 132,114, 148,114,
  570.    148,120, 154,128, 154,136, 152,140,
  571.    152,146, 162,166, 172,166, 182,152,
  572.    182,146, 188,140, 188,132, 186,128,
  573.    186,124, 200,108, 200,102, 192,104,
  574.    184,94, 180,80, 188,92, 192,100,
  575.    200,98, 204,96, 210,88, 206,84,
  576.    216,84, 220,90, 224,90, 226,104,
  577.    230,110, 232,110, 234,104, 234,110,
  578.    236,110, 236,106, 234,104, 236,96,
  579.    244,88, 254,102, 254,106, 260,116,
  580.    264,116, 264,114, 256,104, 256,100,
  581.    264,108, 268,104, 268,100, 264,92,
  582.    264,88, 272,88, 276,84, 278,72,
  583.    272,68, 272,64, 268,64, 268,60,
  584.    274,60, 278,68, 280,68, 282,66,
  585.    278,60, 278,56, 282,56, 282,56,
  586.    272,36, 272,32, 282,32, 282,28,
  587.    286,28, 286,36, 294,42, 296,40,
  588.    290,30, 296,24, 294,20, 300,20,
  589.    298,16, 292,16, 288,14, 276,14,
  590.    276,16, 268,16, 268,14, 252,14,
  591.    252,16, 244,16, 244,14, 230,14,
  592.    228,10, 220,10, 220,8, 216,8,
  593.    212,4, 208,8, 210,8, 210,6,
  594.    212,6, 212,10, 216,10, 216,14,
  595.    212,14, 204,18, 208,24, 204,24,
  596.    200,16, 198,16, 198,20, 200,24,
  597.    188,24, 184,26, 182,22, 180,22,
  598.    180,28, 176,30, 176,28, 178,26,
  599.    168,20, 164,20, 148,34, 148,40,
  600.    152,38, 158,42, 160,40, 160,34,
  601.    164,28, 168,32, 164,36, 166,40,
  602.    160,44, 152,44, 152,40, 150,40,
  603.    150,44, 140,52, 138,52, 140,56,
  604.    140,58, 132,58, 130,66, 134,68,
  605.    142,66, 142,62, 152,58, 158,66,
  606.    158,68, 160,68, 160,62, 152,56,
  607.    158,56, 166,68, 166,64, 172,62,
  608.    172,56, 176,56, 178,58, 180,54,
  609.    184,54, 182,56, 186,60, 176,60,
  610.    170,66, 172,68, 180,68, 180,76,
  611.    172,76, 166,72, 160,76, 152,72,
  612.    152,68, 142,68, 140,70, 134,70,
  613.    130,72,
  614.  
  615.   -1,-1,192,56,
  616.    196,54, 200,68, 196,68, 192,56,
  617.  
  618.   -1,-2};
  619.  
  620.  
  621. int cga2ega(int *PIX,unsigned color)
  622. {
  623.   /* illustrates integer conversion of screen coordinates from */
  624.   /* CGA MED RES graphics mode to 640 x 350 EGA mode  */
  625.  
  626.   int X=0,Y=1,true=X,done=Y;
  627.   int newx,oldx,newy,oldy;
  628.  
  629.   drawstart:;
  630.  
  631.                          /* conversion from 320 x 200 to 640 x 350   */
  632.   oldx= PIX[X]<<1;       /* use a ratio 320 to 640 for the x dimn    */
  633.   oldy=(PIX[Y]*7)/4;     /* use a ratio of 350 to 200 for the y dimn */
  634.  
  635.   while(done!=true)
  636.      {
  637.       X=X+2 ; Y=Y+2;
  638.       if(PIX[X]!=(-1)){
  639.                          newx=PIX[X]<<1;
  640.                          newy=(PIX[Y]*7)/4;
  641.                          writeline(oldx,oldy,newx,newy,color);
  642.                          oldx=newx;
  643.                          oldy=newy;
  644.                         }
  645.       else(done=true);
  646.       }
  647.       true = 0; done = 1;
  648.       if (PIX[X]==PIX[Y]){ X=X+2;Y=Y+2;
  649.                            goto drawstart;
  650.                         }
  651.  
  652.  
  653. }
  654.  
  655.  
  656. main()
  657. {
  658.  
  659.     char buf[4][66];
  660.     int i,j,x,y;
  661.  
  662.  
  663.     if(setcrtmode(EGA)!=EGA)
  664.     {
  665.         puts("Sorry... EGA required.");
  666.         exit(0);
  667.     }
  668.  
  669.  
  670.     flood(BLUE);              /* flood dark blue      */
  671.     linebox(0,0,639,349,RED); /* draw a red box       */
  672.     cga2ega(USA,LCYAN);       /* draw the map of the USA in cyan */
  673.                               /* test the text routine.. white text */
  674.     egatextM("Press any Key To See The World",319,330,BWHITE);
  675.     getch();
  676.  
  677.     flood(RED);                  /* flood red  */
  678.     linebox(0,0,639,349,BWHITE); /* make a white box */
  679.     cga2ega(WORLD,YELLOW);       /* draw the map of the world */
  680.  
  681.     /* tell them who we are */
  682.     egatextM("Another World Class Production by Bill Buckels",
  683.               380,320,BWHITE);
  684.     egatextM("Winnipeg, Manitoba, Canada *** Sept 1991",
  685.               380,335,BWHITE);
  686.     getch();
  687.     setcrtmode(3);
  688.     exit(0);
  689.  
  690. }
  691.  
  692.  
  693.